import { defineStore } from 'pinia'

// defineStore 调用后返回一个函数，调用该函数获得 Store 实体
const testStore = defineStore({
  // id: 必须的，在所有 Store 中唯一
  id: 'myTestState',
  // state: 返回对象的函数
  state: () => ({
    count: 1,
    firstName: 'du',
    secondName: 'junhui',
    tabs: [],
    obj: {},
  }),
  getters: {
    getFullName() {
      return this.firstName + this.secondName
    },
  },
  actions: {
    countPlusOne() {
      this.count++
    },
    countPlus(num) {
      this.count += num
    },
  },
})
export default testStore
